<?php
include("session.php");
include("config.php");
$loc_entity=RLang("user");
if (!validate(LEVEL_RETIRE_USER, "retire_user.php", $db, "user_list.php")) 
    exit();

$id = 0;
if (isset($_GET['id']) && $_GET['id'] >= 0) {
    $id = $_GET['id'];

    $sql = "Update user set level = 0 where id = ?";
    if (!get_db_result($db, $sql, "i", $id)) {
        echo ($sql . " ");
        die(mysqli_error($db));
    }
    $rowcnt = mysqli_affected_rows($db);
    if ($rowcnt == 0) {
        $_SESSION['msgtype'] = "error";
        $_SESSION['msg'] = sprintf(RLang("err_entity_not_found"), $loc_entity, $id);
        header("Location: user_list.php");
    }else{
        $_SESSION['msgtype'] = "msg";
        $_SESSION['msg'] = sprintf(RLang("msg_retire_success"), $loc_entity) ;
        header("Location: user_list.php");
    }
    return true;
}else{
    $_SESSION['msgtype'] = "error";
    $_SESSION['msg'] = sprintf(RLang("err_get_field_miss_or_invalid"), "ID", $id);
    header("Location: user_list.php");
}
?>
